import os
filename = 'PaperAuthor';
ext = '.sql'
directory = filename + "dir\\"
if not os.path.exists(directory):
    os.makedirs(directory)

curFileNum = 0
filehdl = open(filename+ext)

filestr = filehdl.readline()
curLineNum = 0
curfilehdl = open(directory+filename + str(curFileNum) + ext,"w")
curfilehdl.write("BEGIN TRANSACTION;\n")
while filestr is not None:
    curfilehdl.write(filestr)
    filestr = filehdl.readline()
    if filestr is None:
        break
    curLineNum = curLineNum + 1
    if curLineNum>200000:
        curLineNum=0
        curFileNum = curFileNum + 1
        curfilehdl.write("COMMIT;\n")
        curfilehdl.close()
        curfilehdl = open(directory+filename+str(curFileNum)+ext,"w")
        curfilehdl.write("BEGIN TRANSACTION;\n")
if curfilehdl:
    curfilehdl.write("COMMIT;\n")
    curfilehdl.close()
